<script>
import api from '@/api'
import { Descriptions as YsDescriptions } from '@/components/YS'

export default {
  name: 'AdminResourceDetail',
  components: {
    YsDescriptions
  },
  props: {
    id: {
      type: Number,
      default: 0
    }
  },
  data () {
    const _this = this
    return {
      params: {},
      descriptions: {
        title: '菜单资源详情',
        fields: {
          id: this.__('ID'),
          type_text: this.__('类型'),
          pid_text: this.__('上级'),
          path: this.__('路由'),
          resource: this.__('资源'),
          title: this.__('标题'),
          remark: this.__('备注'),
          weigh: this.__('权重'),
          status_text: this.__('状态'),
          create_time: this.__('创建时间'),
          update_time: this.__('更新时间')
        },
        data () {
          _this.params.id = _this.id || _this.$route.query.id
          return api.admin.resource.detail(_this.params).then(response => {
            return Promise.resolve(response.data.data.row)
          }).catch(error => {
            return Promise.reject(error)
          })
        }
      }
    }
  },
  created () {
    this.params.id = this.id || this.$route.query.id
  },
  render () {
    const props = this.descriptions
    return <ys-descriptions { ...{ props } } ></ys-descriptions>
  }
}
</script>
